import store from '../../../repo/store/store'
import EnterpriseLevelAPI from '../../../repo/api/EnterpriseLevelAPI'
import {Toast} from 'vant'
import router from '../../../router'
import {payTool} from '../../../utils/payTool'

let PackageMixIn = {
  data () {
    return {
      firstFreeLimit: 0,
      firstLimit: 0,
      hasBuyGroupLevellimit: 0,
      subscriptionId: 0,
    }
  },
  created () {
    this.fetchData()
    this.getGroupLevelInfo()
  },
  methods: {
    addOrder (targetId, months) {
      payTool.aliPayAddOrderOfEvaluationInvoke({targetId: targetId, months: months,returnUrl:window.location.href})
    },
    getGroupLevelInfo () {
      if (!store.getters.hasLogged) return//未登录
      EnterpriseLevelAPI.getGroupLevelInfo().then((result) => {
        this.firstFreeLimit = result.responseData.firstFreeLimit
        this.firstLimit = result.responseData.firstLimit
        this.hasBuyGroupLevellimit = result.responseData.hasBuyGroupLevellimit
        if (result.responseData.buyInfo) {
          this.subscriptionId = result.responseData.buyInfo.subscriptionId
        }

      })
    },

  }
}

export default PackageMixIn
